package com.gxa.meiye.admin.platform.controller;

import com.gxa.meiye.admin.platform.pojo.vo.*;
import com.gxa.meiye.admin.platform.service.OrderManageService;
import com.gxa.meiye.core.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api
@RestController
@RequestMapping("/platform/ordermanage")
public class OrdermanageController {
    @Resource
    private OrderManageService orderManageService;
    @ApiOperation("订单管理（点击订单管理渲染）")
    @GetMapping("/ordermanage/queryAll")
    public Map queryAll(){
        List<OrderManageVo> orderManageVos = this.orderManageService.queryAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(orderManageVos);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }
    @ApiOperation("搜索订单管理（状态为0-8）")
    @PostMapping("/ordermanage/selectAll")
    public Map selectAll(@RequestBody SelectOrderVo selectOrderVo){
        List<OrderManageVo> orderManageVos;
        if(selectOrderVo.getStatus()==0) {
            orderManageVos=this.orderManageService.selectAll0(selectOrderVo.getStatus(), selectOrderVo.getBegintime(), selectOrderVo.getEndtime(), selectOrderVo.getTempall());
        }else{
            orderManageVos=this.orderManageService.selectAll(selectOrderVo.getStatus(), selectOrderVo.getBegintime(), selectOrderVo.getEndtime(), selectOrderVo.getTempall());
        }
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(orderManageVos);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }
    @ApiOperation("订单详情")
    @PostMapping("/ordermanage/detailsAll")
    public Map detailsAll(@RequestBody DetailsOrderVo detailsOrderVo){
        Map map = new HashMap();
        List<CustomerMationVo> customerMationVos = this.orderManageService.queryUser(detailsOrderVo.getOrder_num(), detailsOrderVo.getStatus());
        List<ProjectMationVo> projectMationVos = this.orderManageService.queryProject(detailsOrderVo.getOrder_num(), detailsOrderVo.getStatus());
        List<ServiceMationVo> serviceMationVos = this.orderManageService.queryService(detailsOrderVo.getOrder_num(), detailsOrderVo.getStatus());
        List<OrderMationVo> orderMationVos = this.orderManageService.queryOrder(detailsOrderVo.getOrder_num(), detailsOrderVo.getStatus());
        map.put("customerMationVo",customerMationVos);
        map.put("serviceProviderVo",projectMationVos);
        map.put("projectMationVo",serviceMationVos);
        map.put("orderManageVo",orderMationVos);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(map);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }


}
